#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
struct tv_to_file {
    FILE*           fp;
    struct timeval  tv;
    unsigned long   sn;
};
struct tv_to_file kttf = {0};


#define UTV_DEBUG(s)                 \
do {\
    extern struct tv_to_file kttf;\
    if(NULL == kttf.fp) {\
        kttf.fp = fopen("/tmp/tvtofile", "w");\
        setbuf(kttf.fp, NULL);\
    }\
    struct timeval tv;\
    gettimeofday(&tv, NULL);\
    int usec = kttf.sn==0?0:(tv.tv_sec*1000000 + tv.tv_usec - kttf.tv.tv_sec*1000000 - kttf.tv.tv_usec);\
    kttf.tv = tv;\
    fprintf(kttf.fp, "%s %d\n", s, usec);\
    kttf.sn ++ ;\
}while(0);


int main()
{
    while(1) {
        CUR("cycr_get")
    }

    return 0;
}
/*    fprintf(kttf.fp, "%s %6lu %lu:%06lu %d\n", kttf.sn, tv.tv_sec, tv.tv_usec, usec);\*/
